package com.ms.service.module.fish.message.server;

import java.nio.ByteBuffer;

import com.ms.service.module.fish.game.GameUser;
import com.ms.service.module.fish.message.FishBaseMessage;
import com.ms.service.module.fish.game.FishDesk;

/**
 * 进入游戏
 * @author cuiwm
 */
public class EnterGameMessage extends FishBaseMessage {
	
    private GameUser user;
    
    public EnterGameMessage(GameUser user) {
    	this.setUser(user);
	}

	public GameUser getUser() {
		return user;
	}

	public void setUser(GameUser user) {
		this.user = user;
	}

	@Override
	public void writeBody(ByteBuffer buf) {
		FishDesk desk = user.getDesk();
		buf.putInt(desk.getId());
		writeString(buf,desk.getGame().getMapRes());
		buf.putInt(desk.getGame().getStagId());
		GameUser[] users = desk.getUsers();
		buf.putInt(desk.getMsize());
		for(GameUser us:users){
			if(us != null) {
				new UserEnterMessage(us).writeBody(buf);
			}
		}
	}

    

}